<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Spherical Bessel Functions of the First and Second Kinds</title>
<link rel="stylesheet" href="../../math.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="Math Toolkit 4.2.1">
<link rel="up" href="../bessel.html" title="Bessel Functions">
<link rel="prev" href="mbessel.html" title="Modified Bessel Functions of the First and Second Kinds">
<link rel="next" href="bessel_derivatives.html" title="Derivatives of the Bessel Functions">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="mbessel.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../bessel.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="bessel_derivatives.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="math_toolkit.bessel.sph_bessel"></a><a class="link" href="sph_bessel.html" title="Spherical Bessel Functions of the First and Second Kinds">Spherical Bessel Functions
      of the First and Second Kinds</a>
</h3></div></div></div>
<h5>
<a name="math_toolkit.bessel.sph_bessel.h0"></a>
        <span class="phrase"><a name="math_toolkit.bessel.sph_bessel.synopsis"></a></span><a class="link" href="sph_bessel.html#math_toolkit.bessel.sph_bessel.synopsis">Synopsis</a>
      </h5>
<p>
        <code class="computeroutput"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">special_functions</span><span class="special">/</span><span class="identifier">bessel</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code>
      </p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">&gt;</span>
<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">sph_bessel</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="identifier">v</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">x</span><span class="special">);</span>

<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 22. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">sph_bessel</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="identifier">v</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 22. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>

<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">&gt;</span>
<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">sph_neumann</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="identifier">v</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">x</span><span class="special">);</span>

<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 22. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">sph_neumann</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="identifier">v</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 22. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
</pre>
<h5>
<a name="math_toolkit.bessel.sph_bessel.h1"></a>
        <span class="phrase"><a name="math_toolkit.bessel.sph_bessel.description"></a></span><a class="link" href="sph_bessel.html#math_toolkit.bessel.sph_bessel.description">Description</a>
      </h5>
<p>
        The functions <a class="link" href="sph_bessel.html" title="Spherical Bessel Functions of the First and Second Kinds">sph_bessel</a>
        and <a class="link" href="sph_bessel.html" title="Spherical Bessel Functions of the First and Second Kinds">sph_neumann</a> return
        the result of the Spherical Bessel functions of the first and second kinds
        respectively:
      </p>
<div class="blockquote"><blockquote class="blockquote"><p>
          sph_bessel(v, x) = j<sub>v</sub>(x)
        </p></blockquote></div>
<div class="blockquote"><blockquote class="blockquote"><p>
          sph_neumann(v, x) = y<sub>v</sub>(x) = n<sub>v</sub>(x)
        </p></blockquote></div>
<p>
        where:
      </p>
<div class="blockquote"><blockquote class="blockquote"><p>
          <span class="inlinemediaobject"><img src="../../../equations/sbessel2.svg"></span>

        </p></blockquote></div>
<p>
        The return type of these functions is computed using the <a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>result
        type calculation rules</em></span></a> for the single argument type T.
      </p>
<p>
        The final <a class="link" href="../../policy.html" title="Chapter 22. Policies: Controlling Precision, Error Handling etc">Policy</a> argument is optional and can
        be used to control the behaviour of the function: how it handles errors,
        what level of precision to use etc. Refer to the <a class="link" href="../../policy.html" title="Chapter 22. Policies: Controlling Precision, Error Handling etc">policy
        documentation for more details</a>.
      </p>
<p>
        The functions return the result of <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
        whenever the result is undefined or complex: this occurs when <code class="computeroutput"><span class="identifier">x</span> <span class="special">&lt;</span> <span class="number">0</span></code>.
      </p>
<p>
        The j<sub>v</sub> function is cyclic like J<sub>v</sub> but differs in its behaviour at the origin:
      </p>
<div class="blockquote"><blockquote class="blockquote"><p>
          <span class="inlinemediaobject"><img src="../../../graphs/sph_bessel.svg" align="middle"></span>

        </p></blockquote></div>
<p>
        Likewise y<sub>v</sub> is also cyclic for large x, but tends to -∞
for small <span class="emphasis"><em>x</em></span>:
      </p>
<div class="blockquote"><blockquote class="blockquote"><p>
          <span class="inlinemediaobject"><img src="../../../graphs/sph_neumann.svg" align="middle"></span>

        </p></blockquote></div>
<h5>
<a name="math_toolkit.bessel.sph_bessel.h2"></a>
        <span class="phrase"><a name="math_toolkit.bessel.sph_bessel.testing"></a></span><a class="link" href="sph_bessel.html#math_toolkit.bessel.sph_bessel.testing">Testing</a>
      </h5>
<p>
        There are two sets of test values: spot values calculated using <a href="http://functions.wolfram.com/" target="_top">functions.wolfram.com</a>,
        and a much larger set of tests computed using a simplified version of this
        implementation (with all the special case handling removed).
      </p>
<h5>
<a name="math_toolkit.bessel.sph_bessel.h3"></a>
        <span class="phrase"><a name="math_toolkit.bessel.sph_bessel.accuracy"></a></span><a class="link" href="sph_bessel.html#math_toolkit.bessel.sph_bessel.accuracy">Accuracy</a>
      </h5>
<div class="table">
<a name="math_toolkit.bessel.sph_bessel.table_sph_bessel"></a><p class="title"><b>Table 8.48. Error rates for sph_bessel</b></p>
<div class="table-contents"><table class="table" summary="Error rates for sph_bessel">
<colgroup>
<col>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
              </th>
<th>
                <p>
                  GNU C++ version 7.1.0<br> linux<br> long double
                </p>
              </th>
<th>
                <p>
                  GNU C++ version 7.1.0<br> linux<br> double
                </p>
              </th>
<th>
                <p>
                  Sun compiler version 0x5150<br> Sun Solaris<br> long double
                </p>
              </th>
<th>
                <p>
                  Microsoft Visual C++ version 14.1<br> Win32<br> double
                </p>
              </th>
</tr></thead>
<tbody><tr>
<td>
                <p>
                  Bessel j: Random Data
                </p>
              </td>
<td>
                <p>
                  <span class="blue">Max = 243ε (Mean = 13.3ε)</span><br> <br>
                  (<span class="emphasis"><em>&lt;cmath&gt;:</em></span> Max = 1.91e+06ε (Mean = 1.09e+05ε))
                </p>
              </td>
<td>
                <p>
                  <span class="blue">Max = 0.978ε (Mean = 0.0445ε)</span><br>
                  <br> (<span class="emphasis"><em>GSL 2.1:</em></span> Max = 1.79e+03ε (Mean = 107ε))
                </p>
              </td>
<td>
                <p>
                  <span class="blue">Max = 243ε (Mean = 33.7ε)</span>
                </p>
              </td>
<td>
                <p>
                  <span class="blue">Max = 245ε (Mean = 16.3ε)</span>
                </p>
              </td>
</tr></tbody>
</table></div>
</div>
<br class="table-break"><div class="table">
<a name="math_toolkit.bessel.sph_bessel.table_sph_neumann"></a><p class="title"><b>Table 8.49. Error rates for sph_neumann</b></p>
<div class="table-contents"><table class="table" summary="Error rates for sph_neumann">
<colgroup>
<col>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
              </th>
<th>
                <p>
                  GNU C++ version 7.1.0<br> linux<br> long double
                </p>
              </th>
<th>
                <p>
                  GNU C++ version 7.1.0<br> linux<br> double
                </p>
              </th>
<th>
                <p>
                  Sun compiler version 0x5150<br> Sun Solaris<br> long double
                </p>
              </th>
<th>
                <p>
                  Microsoft Visual C++ version 14.1<br> Win32<br> double
                </p>
              </th>
</tr></thead>
<tbody><tr>
<td>
                <p>
                  y: Random Data
                </p>
              </td>
<td>
                <p>
                  <span class="blue">Max = 234ε (Mean = 19.5ε)</span><br> <br>
                  (<span class="emphasis"><em>&lt;cmath&gt;:</em></span> Max = 1.6e+06ε (Mean = 1.4e+05ε))
                </p>
              </td>
<td>
                <p>
                  <span class="blue">Max = 0.995ε (Mean = 0.0665ε)</span><br>
                  <br> (<span class="emphasis"><em>GSL 2.1:</em></span> Max = 8.5e+04ε (Mean = 5.33e+03ε))
                </p>
              </td>
<td>
                <p>
                  <span class="blue">Max = 234ε (Mean = 19.8ε)</span>
                </p>
              </td>
<td>
                <p>
                  <span class="blue">Max = 281ε (Mean = 31.1ε)</span>
                </p>
              </td>
</tr></tbody>
</table></div>
</div>
<br class="table-break"><h5>
<a name="math_toolkit.bessel.sph_bessel.h4"></a>
        <span class="phrase"><a name="math_toolkit.bessel.sph_bessel.implementation"></a></span><a class="link" href="sph_bessel.html#math_toolkit.bessel.sph_bessel.implementation">Implementation</a>
      </h5>
<p>
        Other than error handling and a couple of special cases these functions are
        implemented directly in terms of their definitions:
      </p>
<div class="blockquote"><blockquote class="blockquote"><p>
          <span class="inlinemediaobject"><img src="../../../equations/sbessel2.svg"></span>

        </p></blockquote></div>
<p>
        The special cases occur for:
      </p>
<div class="blockquote"><blockquote class="blockquote"><p>
          j<sub>0</sub>= <a class="link" href="../sinc/sinc_pi.html" title="sinc_pi">sinc_pi</a>(x) = sin(x)
          / x
        </p></blockquote></div>
<p>
        and for small <span class="emphasis"><em>x &lt; 1</em></span>, we can use the series:
      </p>
<div class="blockquote"><blockquote class="blockquote"><p>
          <span class="inlinemediaobject"><img src="../../../equations/sbessel5.svg"></span>

        </p></blockquote></div>
<p>
        which neatly avoids the problem of calculating 0/0 that can occur with the
        main definition as x → 0.
      </p>
</div>
<div class="copyright-footer">Copyright © 2006-2021 Nikhar Agrawal, Anton Bikineev, Matthew Borland,
      Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert Holin, Bruno
      Lalande, John Maddock, Evan Miller, Jeremy Murphy, Matthew Pulver, Johan Råde,
      Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg, Daryle
      Walker and Xiaogang Zhang<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="mbessel.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../bessel.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="bessel_derivatives.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
